﻿@using NewLife;
@using System.Reflection
@using XCode
@using XCode.Configuration
@using Microsoft.AspNetCore.Mvc.Rendering;
@{
	//Layout = NewLife.Cube.Setting.Current.Layout;

	var entity = Model as IEntity;
	var fields = ViewBag.Fields as FieldCollection;

	var rv = entity.GetRouteKey();

	Object htmlAttributes = null;
	if (fields.Any(e => e.ItemType.EqualIgnoreCase("file", "image"))) htmlAttributes = new { enctype = "multipart/form-data" };
}

<div class="col-12">
	@await Html.PartialAsync("_Form_Header", entity)
	@using (Html.BeginForm("Add", null, rv, FormMethod.Post, null, htmlAttributes))
	{
		<div class="card">
			<ul>
				@foreach (var item in ViewData.ModelState.Values)
				{
					foreach (var error in item.Errors)
					{
						<li>@error.Exception</li>
					}
				}
			</ul>
			@await Html.PartialAsync("_Form_Body", entity)
		</div>
	}
</div>